#define  _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

void SelectSort(int a[],int n,int i) {
	int j, k;
	if (i == n - 1) {
		return;
	}
	else {
		k = i;
		for (int j = i + 1; j < n; j++) 
			if (a[j] < a[i])
				k = j;
			if(k!=i)
				swap(a[i], a[k]);
		SelectSort( a,  n,  i+1);
	}
}

int main() {
	int a[] = { 9,8,7,6,5,4,3,2,1 };
	int n = sizeof(a) / sizeof(a[1]);
	int i = 0;
	SelectSort(a,n,i);
	for (int j = 0; j < n; j++) {
		printf("%d ", a[j]);
	}
	return 0;
}